{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'c', 'b', 'a'}\n",
      "{'c', 'f', 'e'}\n",
      "{'c', 'f', 'e'}\n"
     ]
    }
   ],
   "source": [
    "## set 集合\n",
    "## frozenset （不可变）\n",
    "## 无序，不可变\n",
    "\n",
    "## set 初始化\n",
    "# s = set('abcdee')\n",
    "# s = set(['a', 'b', 'c', 'd', 'e'])\n",
    "# s = {'a', 'b', 'c', 'd', 'e'}\n",
    "s = {'a', 'b'}\n",
    "s.add('c')\n",
    "print(s)\n",
    "\n",
    "\n",
    "# print(s)\n",
    "\n",
    "## frozenset 初始化\n",
    "## fronzeset 可以作为dict的key\n",
    "# fs = frozenset('abcde')\n",
    "# print(fs)\n",
    "\n",
    "\n",
    "## update 合集 （并集）\n",
    "another_set = set('def')\n",
    "s.update(another_set)\n",
    "\n",
    "\n",
    "another_set = set('cef')\n",
    "print(another_set)\n",
    "## 差集\n",
    "# re_set = s.difference(another_set)\n",
    "## 差集\n",
    "# re_set = s - another_set\n",
    "## 交集\n",
    "re_set = s & another_set\n",
    "## 并集\n",
    "# re_set = s | another_set\n",
    "print(re_set)\n",
    "\n",
    "## 判断在集合中 \n",
    "if 'c' in re_set:\n",
    "    print('i am in set')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
